package com.springcloud.tread.service;

import cn.hutool.core.collection.CollUtil;
import com.springcloud.tread.pojo.Index;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@CacheConfig(cacheNames = "indexes")//表示添加到缓存里的名字
public class IndexService {

    private List<Index> list;

    //获取数据
    @Cacheable(key = "'all_codes'")//如果缓存里面有则直接从里面获取，没有返回空信息
    public List<Index> get() {
        Index index = new Index();
        index.setName("没有！！");
        index.setCode("没有！！");
        return CollUtil.toList(index);
    }
}
